package com.tencent.wxcloudrun.controller.fangdong;

import com.tencent.wxcloudrun.config.ApiResponse;
import com.tencent.wxcloudrun.pojo.dto.req.RejectOrAgreeReq;
import com.tencent.wxcloudrun.pojo.dto.resp.*;
import com.tencent.wxcloudrun.service.business.fangdong.LandTodoService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping("/landTodo")
public class LandTodoController {

    @Resource
    private LandTodoService landTodoService;

    /**
     * var 传  tenant    land
     */
    @GetMapping("/houseApplyPage")
    public ApiResponse<List<LandHouseApplyPageResp>> houseApplyPage(@RequestParam("var") String var) {
        return new ApiResponse<>(landTodoService.houseApplyPage(var));
    }

    @GetMapping("/getTenantInfo")
    public ApiResponse<GetTenantInfoResp> getTenantInfo(@RequestParam("id") String id) {
        return new ApiResponse<>(landTodoService.getTenantInfo(id));
    }

    @GetMapping("/getZuFangData")
    public ApiResponse<GetZuFangDataResp> getZuFangData(@RequestParam("id") String id) {
        return new ApiResponse<>(landTodoService.getZuFangData(id));
    }

    /**
     * 【房东确认】节点的处理   拒绝或同意   state传1就是同意，传2就是拒绝
     * 如果是拒绝的话，前端要弹窗让房东填写拒绝原因 reason
     */
    @GetMapping("/rejectOrAgree")
    public ApiResponse<String> rejectOrAgree(@RequestParam("id") String id, @RequestParam("state") String state,
                                             @RequestParam("reason") String reason) {
        return new ApiResponse<>(landTodoService.rejectOrAgree(id, state, reason));
    }

    /**
     * 【房东确认】节点的处理 - 支持直接传递收租方式数据
     * 拒绝或同意   state传1就是同意，传2就是拒绝
     * 如果是拒绝的话，前端要弹窗让房东填写拒绝原因 reason
     */
    @PostMapping("/rejectOrAgreeWithData")
    public ApiResponse<ContractGenerateResp> rejectOrAgreeWithData(@RequestBody RejectOrAgreeReq req) {
        return new ApiResponse<>(landTodoService.rejectOrAgreeWithData(req));
    }

    /**
     * 费用清单
     */
    @GetMapping("/feeList")
    public ApiResponse<FeeDataResp> feeList(@RequestParam("id") String id) {
        return new ApiResponse<>(landTodoService.feeList(id));
    }

    /**
     * 手动确认收款
     */
    @GetMapping("/handConfirm")
    public ApiResponse<String> handConfirm(@RequestParam("id") String id) {
        return new ApiResponse<>(landTodoService.handConfirm(id));
    }

    /**
     * 待办中的 退租申请列表   var 传  tenant    land
     */
    @GetMapping("/leaseApplyList")
    public ApiResponse<List<LeaseApplyListResp>> leaseApplyList(@RequestParam("var") String var) {
        return new ApiResponse<>(landTodoService.leaseApplyList(var));
    }

    /**
     * 房东侧的退租详情信息
     */
    @GetMapping("/leaseDetail")
    public ApiResponse<LeaseDetailResp> leaseDetail(@RequestParam("leaseId") String leaseId) {
        return new ApiResponse<>(landTodoService.leaseDetail(leaseId));
    }

    /**
     * 租客电话获取
     */
    @GetMapping("/leaseGetTenantPhone")
    public ApiResponse<String> leaseGetTenantPhone(@RequestParam("leaseId") String leaseId) {
        return new ApiResponse<>(landTodoService.leaseGetTenantPhone(leaseId));
    }

    /**
     * 拒绝与同意租客的退房申请  dealType 1 拒绝 2 同意
     */
    @GetMapping("/dealLeaseApply")
    public ApiResponse<String> dealLeaseApply(@RequestParam("leaseId") String leaseId, @RequestParam("dealType") String dealType) {
        return new ApiResponse<>(landTodoService.dealLeaseApply(leaseId, dealType));
    }

    /**
     * 两个首页上的待办数量   房东页就传 land 租客页就传 tenant
     */
    @GetMapping("/getTodoCount")
    public ApiResponse<GetTodoCountResp> getTodoCount(@RequestParam("type") String type) {
        return new ApiResponse<>(landTodoService.getTodoCount(type));
    }
}
